package com.hong.spring.common.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;

/**
 * @Auther: csh
 * @Date: 2020/7/9 17:12
 * @Description:负责发布消息
 */
public class UserEventPublisher implements ApplicationEventPublisherAware {
    private ApplicationEventPublisher publisher;
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.publisher = applicationEventPublisher;
    }

    public void publish(){
        UserEvent userEvent = new UserEvent(this);
        publisher.publishEvent(userEvent);
    }
}
